package com.mingyuan.library.domain.lending.patron.event;

import com.mingyuan.library.domain.lending.patron.enums.PatronType;
import com.mingyuan.library.domain.lending.patron.model.valueobject.PatronId;
import lombok.NonNull;
import lombok.Value;

import java.time.Instant;
import java.util.UUID;

/**
 * 创建读者
 */
@Value
public class PatronCreated implements PatronEvent {
        @NonNull
        UUID eventId = UUID.randomUUID();
        @NonNull
        Instant when;
        @NonNull UUID patronId;
        @NonNull PatronType patronType;

        public static PatronCreated now(PatronId patronId, PatronType type) {
            return new PatronCreated(Instant.now(), patronId.getPatronId(), type);
        }
    }